package cn.tedu.spring.example;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by IntelliJ IDEA.
 *
 * @author zq
 * @version 1.0
 * @create 2024-08-02 10:19
 * @since jdk1.8
 */
public class TestUser {
    /*
     * 1.Spring Framework创建Spring Bean对象,并放在Ioc容器中.
     * 2.从Ioc容器中获取Java对象
     * 3.调用run()方法测试
     * */
    public static void main(String[] args) {
        // 创建Spring容器
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext("cn.tedu.spring.example");
        // 从Spring容器中获取Java对象
        User user = context.getBean(User.class);
        // 调用run()方法测试
        user.run();
        //通过xml配置文件创建Spring容器
        //ClassPathXmlApplicationContext context1 =
        // new ClassPathXmlApplicationContext("application.xml");
        //User user1 = context1.getBean(User.class);
        //user1.run();

    }
}
